<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
       <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
       <%@page import="org.lanqiao.dxzf.entity.ServiceAll"%>
<%@page import="org.lanqiao.dxzf.entity.Page"%>
       
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <link type="text/css" rel="stylesheet" media="all" href="${pageContext.request.contextPath}/css/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="${pageContext.request.contextPath}/css/global_color.css" /> 
    </head>
    <body>
        <!--Logo区域开始-->
        <%@include file="../include/header.jsp"%>
        <!--导航区域结束-->
        <!--主要区域开始-->
	<div id="main">
		<form
			action="${pageContext.request.contextPath}/showServicelist.do"
			method="post">
			<!--查询-->
			<div class="search_add">
				<div>
					OS 账号：<input type="text" name="sosname" value="${sservice.sosname}"
						class="width100 text_search" />
				</div>
				<div>
					服务器 IP：<input type="text" name="sip" value="${sservice.sip}"
						class="width100 text_search" />
				</div>
				<div>
					身份证：<input type="text" name="sidcard" value="${sservice.sidcard}"
						class="text_search" />
				</div>
				<div>
					状态： <select class="select_search" name="sstatus">
						<option>全部</option>
						<option
							<c:if test="${sservice.sstatus=='开通'}"> selected="selected"</c:if>>开通</option>
						<option
							<c:if test="${sservice.sstatus=='暂停'}"> selected="selected"</c:if>>暂停</option>
						<option
							<c:if test="${sservice.sstatus=='删除'}"> selected="selected"</c:if>>删除</option>
					</select>
				</div>
				<div>
					<input type="submit" value="搜索" class="btn_search" />
				</div>
				<input type="button" value="增加" class="btn_add"
					onclick="location.href='${pageContext.request.contextPath}/showServiceadd.do';" />
			</div>
			<!--删除的操作提示-->
			<div id="operate_result_info" class="operate_success">
				<img src="${pageContext.request.contextPath}/images/close.png"
					onclick="this.parentNode.style.display='none';" />
			</div>
			<!--数据区域：用表格展示数据-->
			<div id="data">
				<table id="datalist">
					<tr>
						<th class="width50">业务ID</th>
						<th class="width70">账务账号ID</th>
						<th class="width150">身份证</th>
						<th class="width70">姓名</th>
						<th>OS 账号</th>
						<th class="width50">状态</th>
						<th class="width100">服务器 IP</th>
						<th class="width100">资费</th>
						<th class="width200"></th>
					</tr>

					<c:forEach items="${requestScope.service}" var="b">
						<tr>
							<td><a
								href="${pageContext.request.contextPath}/showServicedetail.do?sid=${b.sid}"
								title="查看明细">${b.sid}</a></td>
							<td>${b.saccountid}</td>
							<td>${b.sidcard}</td>
							<td>${b.sname}</td>
							<td>${b.sosname}</td>
							<td>${b.sstatus}</td>
							<td>${b.sip}</td>
							<td>${b.scostname}</td>
							<td class="td_modi"><c:if test="${b.sstatus == '开通'}">
									<input type="button" value="暂停" class="btn_pause"
										onclick="setStop(${b.sid});" />
									<input type="button" value="修改" class="btn_modify"
										onclick="location.href='${pageContext.request.contextPath}/showServiceupdate.do?sid=${b.sid}';" />
									<input type="button" value="删除" class="btn_delete"
										onclick="deleteAccount(${b.sid});" />
								</c:if> <c:if test="${b.sstatus == '暂停'}">
									<input type="button" value="开通" class="btn_start"
										onclick="setStart(${b.sid});" />
									<input type="button" value="修改" class="btn_modify"
										onclick="location.href='${pageContext.request.contextPath}/showServiceupdate.do?sid=${b.sid}';" />
									<input type="button" value="删除" class="btn_delete"
										onclick="deleteAccount(${b.sid});" />
								</c:if></td>
						</tr>
					</c:forEach>
				</table>
				<p>
					业务说明：<br /> 1、创建即开通，记载创建时间；<br /> 2、暂停后，记载暂停时间；<br />
					3、重新开通后，删除暂停时间；<br /> 4、删除后，记载删除时间，标示为删除，不能再开通、修改、删除；<br />
					5、业务账号不设计修改密码功能，由用户自服务功能实现；<br /> 6、暂停和删除状态的账务账号下属的业务账号不能被开通。
				</p>
			</div>
			<!--分页-->
			<div id="pages">
				共${totalRecord}条数据 每页${pageSize}条 页次 ${currentPage}/${pageCount}页
				<c:choose>
					<c:when test="${currentPage == 1}">
						<!--如果 -->
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=${currentPage+1}">下一页</a>
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=${pageCount}">尾页</a>
					</c:when>
					<c:when test="${currentPage == pageCount}">
						<!--否则 -->
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=1">首页</a>
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=${currentPage-1}">上一页</a>
					</c:when>
					<c:otherwise>
						<!--否则 -->
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=1">首页</a>
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=${currentPage-1}">上一页</a>
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=${currentPage+1}">下一页</a>
						<a
							href="${pageContext.request.contextPath}/showServicelist.do?currentPage=${pageCount}">尾页</a>
					</c:otherwise>
				</c:choose>
			</div>
		</form>
	</div>
	<!--主要区域结束-->
	<div id="footer"></div>
	<script language="javascript" type="text/javascript">
            //删除
            function deleteAccount(a) {            	
                var r = window.confirm("确定要删除此业务账号吗？删除后将不能恢复。");
                if(r)
                	window.location.href="${pageContext.request.contextPath}/servicedelete.do?sid="+a;
                
            }
            //暂停
            function setStop(a) {
                var r = window.confirm("确定要暂停此业务账号吗？");
                if(r)
                	window.location.href="${pageContext.request.contextPath}/servicestop.do?sid="+a;
                
            }
            //开通
            function setStart(a) {
                var r = window.confirm("确定要开通此业务账号吗？");
                if(r)
                	window.location.href="${pageContext.request.contextPath}/servicestart.do?sid="+a;
                
            }
            //显示删除成功或失败
            var i = "${requestScope.flag1}";
            if(i == '1'){
            	document.getElementById("operate_result_info").innerHTML="删除成功!";
            	showResult();
            }
            if(i == '0'){
            	document.getElementById("operate_result_info").innerHTML="删除失败!";
            	showResult();
            }
            if(i == '11'){
            	document.getElementById("operate_result_info").innerHTML="开通成功!";
            	showResult();
            }
            if(i == '00'){
            	document.getElementById("operate_result_info").innerHTML="开通失败!";
            	showResult();
            }
            if(i == '111'){
            	document.getElementById("operate_result_info").innerHTML="暂停成功!";
            	showResult();
            }
            if(i == '000'){
            	document.getElementById("operate_result_info").innerHTML="暂停失败!";
            	showResult();
            }
            function showResult() {          	
                showResultDiv(true);
                window.setTimeout("showResultDiv(false);", 3000);
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("operate_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }
        </script>
         <div id="footer">
           
        </div>
        <script type="text/javascript" language="javascript">
        //根据权限显示信息
        var listPrivs = "${sessionScope.listPrivs}";
        for(var p of listPrivs){
        if(p=="1")  {document.getElementById("p1").style.display="block";}
        if(p=="2")  {document.getElementById("p2").style.display="block";}
        if(p=="3")	{document.getElementById("p3").style.display="block";}
        if(p=="4")	{document.getElementById("p4").style.display="block";}
        if(p=="5")	{document.getElementById("p5").style.display="block";}
        if(p=="6")	{document.getElementById("p6").style.display="block";}
        if(p=="7")	{document.getElementById("p7").style.display="block";}
        }
        </script>
</body>
</html>
